package org.barad.voiceuserinterface.widgets;

import java.util.Collections;
import java.util.LinkedList;

public class Group extends Widget {
	private LinkedList<Widget> widgets;
	
	public Group() {
		this.widgets = new LinkedList<Widget>(); 
	}
	
	public void add(Widget widget) {
		if (!widgets.contains(widget)) {
			widgets.add(widget);
		}
	}
	
	public void remove(Widget widget) {
		widgets.remove(widget);
	}
	
	@Override
	public void interact() {
	    Collections.sort(widgets);
		for (Widget w: widgets) {
			w.interact();
		}
	}
}